clear all
global master_folder "/Users/christopherrauh/Dropbox/JEEA_replication/"
cd "$master_folder"

local month=8
local year=2020


import delimited "merged_1_3_topics30_200/merged_1_3_topics30_200_m`month'_y`year'.csv", clear 

save temp.dta, replace


local f=1
local topics=30
insheet using "RandomForest1_3_200_0_superall_topics`topics'_0_`f'.csv", clear
keep if dep=="ons_anyviolence`f'"

merge 1:1 isocode year month using temp.dta

generate time=ym(year, month)
format time %tm
egen countryid = group(isocode)
tsset countryid time

generate lntokens=ln(tokens)

generate lnpop=ln(populationwb)

*Table E3
regress lntokens  democracy4 democracy3 democracy2 democracy1 democracy0 i.time, r
outreg2 using "$master_folder/figures_superall/TableE1", keep(democracy4 democracy3 democracy2 democracy1 democracy0) replace

regress lntokens democracy4 democracy3 democracy2 democracy1 democracy0 anyviolence i.time, r
outreg2 using "$master_folder/figures_superall/TableE1", keep(democracy4 democracy3 democracy2 democracy1 democracy0 anyviolence)

regress lntokens democracy4 democracy3 democracy2 democracy1 democracy0 anyviolence lnpop i.time, r
outreg2 using "$master_folder/figures_superall/TableE1", keep(democracy4 democracy3 democracy2 democracy1 democracy0 anyviolence populationwb) excel


*Table E2
gen repressed=democracy2==1 | democracy3==1


rocreg ons_anyviolence`f' text mine   if mine!=. & repressed==1, noboots
rocreg ons_anyviolence`f' text mine   if mine!=. & repressed==0, noboots

rocreg ons_anyviolence`f' text mine   if mine!=. & repressed==1 & anyviolence_dp>119, noboots
rocreg ons_anyviolence`f' text mine   if mine!=. & repressed==0  & anyviolence_dp>119, noboots

drop repressed

*robustness to a different definition of repressed
gen repressed= democracy1==1 | democracy2==1  | democracy3==1

rocreg ons_anyviolence`f' text mine   if mine!=. & repressed==1, noboots
rocreg ons_anyviolence`f' text mine   if mine!=. & repressed==0, noboots

rocreg ons_anyviolence`f' text mine   if mine!=. & repressed==1 & anyviolence_dp>119, noboots
rocreg ons_anyviolence`f' text mine   if mine!=. & repressed==0  & anyviolence_dp>119, noboots

erase temp.dta
